home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / ROUTE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  153 lines

  1. /*
  2.  * INET        An implementation of the TCP/IP protocol suite for the LINUX
  3.  *        operating system.  INET  is implemented using the  BSD Socket
  4.  *        interface as the means of communication with the user level.
  5.  *
  6.  *        Definitions for the IP router.
  7.  *
  8.  * Version:    @(#)route.h    1.0.4    05/27/93
  9.  *
  10.  * Authors:    Ross Biro, <bir7@leland.Stanford.Edu>
  11.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12.  * Fixes:
  13.  *        Alan Cox    :    Reformatted. Added ip_rt_local()
  14.  *        Alan Cox    :    Support for TCP parameters.
  15.  *        Alexey Kuznetsov:    Major changes for new routing code.
  16.  *        Mike McLagan    :    Routing by source
  17.  *
  18.  *        This program is free software; you can redistribute it and/or
  19.  *        modify it under the terms of the GNU General Public License
  20.  *        as published by the Free Software Foundation; either version
  21.  *        2 of the License, or (at your option) any later version.
  22.  */
  23. #ifndef _ROUTE_H
  24. #define _ROUTE_H
  25.  
  26. #include <linux/config.h>
  27. #include <net/dst.h>
  28. #include <linux/in_route.h>
  29. #include <linux/rtnetlink.h>
  30. #include <linux/route.h>
  31.  
  32. #ifndef __KERNEL__
  33. #warning This file is not supposed to be used outside of kernel.
  34. #endif
  35.  
  36. #define RT_HASH_DIVISOR            256
  37.  
  38. /*
  39.  * Prevents LRU trashing, entries considered equivalent,
  40.  * if the difference between last use times is less then this number.
  41.  */
  42. #define RT_CACHE_BUBBLE_THRESHOLD    (5*HZ)
  43.  
  44.  
  45. #define RTO_ONLINK    0x01
  46. #define RTO_TPROXY    0x80000000
  47.  
  48. #ifdef CONFIG_IP_TRANSPARENT_PROXY
  49. #define RTO_CONN    RTO_TPROXY
  50. #else
  51. #define RTO_CONN    0
  52. #endif
  53.  
  54. struct rt_key
  55. {
  56.     __u32            dst;
  57.     __u32            src;
  58.     int            iif;
  59.     int            oif;
  60. #ifdef CONFIG_IP_ROUTE_FWMARK
  61.     __u32            fwmark;
  62. #endif
  63.     __u8            tos;
  64.     __u8            scope;
  65. };
  66.  
  67. struct rtable
  68. {
  69.     union
  70.     {
  71.         struct dst_entry    dst;
  72.         struct rtable        *rt_next;
  73.     } u;
  74.  
  75.     unsigned        rt_flags;
  76.     unsigned        rt_type;
  77.  
  78.     __u32            rt_dst;    /* Path destination    */
  79.     __u32            rt_src;    /* Path source        */
  80.     int            rt_iif;
  81.  
  82.     /* Info on neighbour */
  83.     __u32            rt_gateway;
  84.  
  85.     /* Cache lookup keys */
  86.     struct rt_key        key;
  87.  
  88.     /* Miscellaneous cached information */
  89.     __u32            rt_spec_dst; /* RFC1122 specific destination */
  90.  
  91. #ifdef CONFIG_IP_ROUTE_NAT
  92.     __u32            rt_src_map;
  93.     __u32            rt_dst_map;
  94. #endif
  95. };
  96.  
  97. extern struct rtable     *rt_hash_table[RT_HASH_DIVISOR];
  98.  
  99. struct ip_rt_acct
  100. {
  101.     __u32     o_bytes;
  102.     __u32     o_packets;
  103.     __u32     i_bytes;
  104.     __u32     i_packets;
  105. };
  106.  
  107. extern struct ip_rt_acct ip_rt_acct[256];
  108.  
  109. extern void        ip_rt_init(void);
  110. extern void        ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw,
  111.                        u32 src, u8 tos, struct device *dev);
  112. extern void        ip_rt_advice(struct rtable **rp, int advice);
  113. extern void        rt_cache_flush(int how);
  114. extern int        ip_route_output(struct rtable **, u32 dst, u32 src, u32 tos, int oif);
  115. extern int        ip_route_input(struct sk_buff*, u32 dst, u32 src, u8 tos, struct device *devin);
  116. extern unsigned short    ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu);
  117. extern void        ip_rt_send_redirect(struct sk_buff *skb);
  118.  
  119. extern unsigned        inet_addr_type(u32 addr);
  120. extern void        ip_rt_multicast_event(struct in_device *);
  121. extern int        ip_rt_ioctl(unsigned int cmd, void *arg);
  122. extern void        ip_rt_get_source(u8 *src, struct rtable *rt);
  123. extern int        ip_rt_dump(struct sk_buff *skb,  struct netlink_callback *cb);
  124.  
  125.  
  126. extern __inline__ void ip_rt_put(struct rtable * rt)
  127. {
  128.     if (rt)
  129.         dst_release(&rt->u.dst);
  130. }
  131.  
  132. extern __u8 ip_tos2prio[16];
  133.  
  134. extern __inline__ char rt_tos2priority(u8 tos)
  135. {
  136.     return ip_tos2prio[IPTOS_TOS(tos)>>1];
  137. }
  138.  
  139. extern __inline__ int ip_route_connect(struct rtable **rp, u32 dst, u32 src, u32 tos, int oif)
  140. {
  141.     int err;
  142.     err = ip_route_output(rp, dst, src, tos, oif);
  143.     if (err || (dst && src))
  144.         return err;
  145.     dst = (*rp)->rt_dst;
  146.     src = (*rp)->rt_src;
  147.     ip_rt_put(*rp);
  148.     *rp = NULL;
  149.     return ip_route_output(rp, dst, src, tos, oif);
  150. }
  151.  
  152. #endif    /* _ROUTE_H */
  153.